<?php 
$helper = Mage::helper('core');
$curreny = Mage::app()->getStore()->getCurrentCurrencyCode();
$order = $this->getOrder();
?>

<?php echo $this->getChildHtml('gc_billing')?>

<div id='gc_box'>
	<div class='title'><?php echo $this->__('Credit And Debit Card Information')?></div>
	<div class='content'>
		<table class='left-container'>
	        <thead>
	            <tr>
	            <th colspan="3"><?php echo $this->__('Order Summary')?></th>
	            </tr>
	        </thead>
            <tbody>
            	<tr><th><?php echo $this->__('Subtotal')?></th><td><?php echo $curreny?></td><td align="right"> <?php echo $helper->currency($order->getSubtotal());?></td></tr>
            	<tr><th><?php echo $this->__('Shipping Amount')?></th><td><?php echo $curreny?></td><td align="right"> <?php echo $helper->currency($order->getShippingAmount());?></td>
            	<tr class="total"><th><?php echo $this->__('Grand Total')?></th><td><?php echo $curreny?></td><td align="right"><?php echo $helper->currency($order->getGrandTotal());?></td></tr>       
            	<tr>
		            <td colspan="3" class="sidebox">
			        	<p><<?php echo $this->__('Additional payment security with')?>:</p>
			        	<span class="ir paymentSecure"><?php echo $this->__('verified by visa, mastercard secure code')?></span>
		        	</td>
		        </tr>
        	</tbody>
        </table>

		<div class='right-container'>
			<div>
			<p>
			<?php echo $this->__('We accept the following credit/debit cards. Please select a card type, complete the information below, and click Continue.')?>
			<br>
			(<?php echo $this->__('Note: For security purposes, we will not save any of your credit card data.')?>)
			</p>
			<ul id="banks" class="clearfix">
				<li>
					<label title="Visa" for="paymethod1" class="GlobalCollect1"></label>
					<input type="radio" value="1" name="paymethod" id="paymethod1">
				</li>
				<li>
					<label title="American Express" for="paymethod2" class="GlobalCollect2"></label>
					<input type="radio" value="2" name="paymethod" id="paymethod2"></li>
				<li>
					<label title="Mastercard" for="paymethod3" class="GlobalCollect3"></label>
					<input type="radio" value="3" name="paymethod" id="paymethod3">
				</li>
				<li>
					<label title="Delta Online" for="paymethod111" class="GlobalCollect111"></label>
					<input type="radio" value="111" name="paymethod" id="paymethod111">
				</li>
				<li>
					<label title="Visa Debit" for="paymethod114" class="GlobalCollect114"></label>
					<input type="radio" value="114" name="paymethod" id="paymethod114">
				</li>
				<li>
					<label title="Mastercard Debit" for="paymethod119" class="GlobalCollect119"></label>
					<input type="radio" value="119" name="paymethod" id="paymethod119">
				</li>
				<li>
					<label title="Visa Electron" for="paymethod122" class="GlobalCollect122"></label>
					<input type="radio" value="122" name="paymethod" id="paymethod122">
				</li>
				<li>
					<label title="JCB" for="paymethod125" class="GlobalCollect125"></label>
					<input type="radio" value="125" name="paymethod" id="paymethod125">
				</li>
			</ul>
			<div class='clear'></div>
			</div>

			<iframe style='display:none;' id="gc_checkout_iframe" class="hide" width="99%" height="360" scrolling="no" frameborder="0" src="javascript:false"></iframe>
			<table id="fake_paymethod">
				<tbody>
				    <tr>
					<th><?php echo $this->__('Card Number')?>:</th>
					<td><input type="text" disabled="disabled"> <span class="required">*</span></td>
				    </tr>
				    <tr>
					<th><?php echo $this->__('Expiration Date')?>:</th>
					<td>
					    <select disabled="disabled">
						<option value=""><?php echo $this->__('Month')?></option>
					    </select>
					    <select disabled="disabled">
						<option value=""><?php echo $this->__('Year')?></option>
					    </select>
					    <span class="required">*</span>
					</td>
				    </tr>
				    <tr>
					<th><?php echo $this->__('Security Code')?>:</th>
					<td><input type="text" disabled="disabled" class="securityCode"> <span class="required">*</span></td>
				    </tr>
				    <tr>
					<th></th>
					<td><a href='javascript:void(0);'class="gcContinuePendingBtn"><?php echo $this->__('Continue')?></a></td>
					</tr>
				</tbody>
			</table>

			<div id='gc_mask' ><div class='loadmask-msg'></div></div>
		</div>
		<div class='clear'></div>
		<div id='payTips'>
		    <p>* <?php echo $this->__('Please wait while we process your transaction. It will be done within a moment')?>....</p>
		    <p>* <?php echo $this->__('Browsers lower than IE 6.0 not supported')?></p>
		</div>
	</div>

</div>   
<script type="text/javascript">
jQuery.noConflict(); 
jQuery(document).ready(function($){
	$('#banks li input').click(function(){
		var paymentId = $(this).val();
		$('#gc_mask').show();
		$.ajax({
			url:'<?php echo $this->getUrl('globalcollect/index/checkoutProcess', array('_secure' => true))?>',
			async: false,
			cache: false,
			data: {'orderId': <?php echo $order->getIncrementId()?>, 'paymentId': paymentId},
			success:function(data){
				if (data.error == 'false'){
					$('#gc_checkout_iframe').attr('src', data.src).load(function(){
						$('#fake_paymethod').hide();
						$('#gc_checkout_iframe').show();
						$('#gc_mask').hide();
					});
					
				} else {
					alert(data.errorMsg);
					$('#fake_paymethod').show();
					$('#gc_mask').hide();
				}
			},
			type:'POST',
			dataType:'json'
		});
		
	});

});
</script>